package com.xingxin.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xingxin.entity.Attribute;
import com.xingxin.service.AttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

@Component("enterpriseBaseController")
public class StaticTest {

    @Resource
    AttributeService attributeService;

    private static AttributeService staticAttributeService;

    @PostConstruct
    public void init(){
        this.staticAttributeService = attributeService;
    }

    public static List<Attribute> findAllFather(){
        List<Attribute> attributes = staticAttributeService.selectAll();

        return attributes;
    }

    public Attribute findOneFather(){
        QueryWrapper<Attribute> wrapper = new QueryWrapper<>();
        Attribute attribute = new Attribute();
        attribute.setAttrId(2);
        wrapper.setEntity(attribute);
        Attribute attributeOne = attributeService.getBaseMapper().selectOne(wrapper);
        System.out.println("attributeOne = " + attributeOne);
        return attributeOne;
    }
}
